<template>
	<div id="footmark">
		<div class="foot_content">
			<div class="title">
				我的收藏
			</div>
			<div class="foot_list">
				<div class="item_content" v-for="(item,index) in tableData" @click.stop="changeRouter('product',item.id)">
					<div class="footmark_item  my-flex-between">
						<span class="one-line">{{item.name}}</span>
						<span class="companyname one-line">{{item.userName}}</span>
						<span class="unit">{{item.priceCN}}</span>
						<span class="img my-flex-col-center"><img src="../../assets/priceType/shop.png"/></span>
					</div>
				</div>
				<!--分页-->
				<div class="page-change my-flex-center" v-if="tableData.length!=0">
					<div class="my-flex-center">
						<img src="../../assets/priceType/icon_left.png" @click="pageChange(params.pageNum-1)"/>
						<span class="color-red">{{params.pageNum}}</span>
						<span> / {{Math.ceil(total/10)}}</span>
						<img src="../../assets/priceType/icon_right.png" @click="pageChange(params.pageNum+1)"/>
						<span>跳转至第</span>
						<el-input-number size='mini' v-model="jumpPage" controls-position="right" :precision='0' :min="1" :max="Math.ceil(total/10)"></el-input-number>
						<span>页</span>
						<li class="jump bg-red my-btn" @click="pageChange(jumpPage)">跳转</li>
					</div>
				</div>
				<v-empty v-if="tableData.length==0"></v-empty>

			</div>
		</div>

	</div>
</template>

<script>
	import $ from 'jquery';
	import service from '@/js/services/collectservice.js';
	export default {
		inject: ['reload', 'closeLoading', 'openLoading', 'hasPermission'],

		data() {
			return {
				currrentId: 6,
				params: {
					pageNum: 1,
					pageSize: 10
				},
				tableData: [],
				total: 0,
				jumpPage:0,
			}
		},
		mounted() {
			this.getMycollectPage();
		},
		methods: {
			...service,
			pageChange(page) {
				let pageTotal = Math.ceil(this.total / 10);
				if(page < 1 || page > pageTotal || page==this.params.pageNum) {
					return;
				}
				this.params.pageNum = page;
				this.getMycollectPage(page);
			},
			goProduct(item) {
				let params = {
					detailid: item.id,
					toPage: 'productDetail'
				};
				this.tool.webkitExecute(params, () => {
					this.$router.push({
						path: '/product/' + item.id
					});
				});
			},
			addShopCar(id, index) {
				let self = this;
				//				shopcarservice.shopcarAdd(self, id, 1, 0, res => {
				//					self.$toast('加入成功!');
				//				});
			},
			changeRouter(url, id) {
				this.$router.push({
					path: url,
					query: {
						id: id
					}
				});
			}
		}
	}
</script>

<style lang="less" src="../../less/page/center/collect.less"></style>